from django import forms

from la import models


class SyrInfoModelForm(forms.ModelForm):
    class Meta:
        model = models.sypeople
        fields = ["name","store"]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            # print(name)
            field.widget.attrs = {"class": 'form-control m-b-15'}

class ZffsInfoModelForm(forms.ModelForm):
    class Meta:
        model = models.zffslist
        fields = ["name"]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            # print(name)
            field.widget.attrs = {"class": 'form-control m-b-15'}

class BrandInfoModelForm(forms.ModelForm):
    class Meta:
        model = models.brandlist
        fields = ["name"]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            # print(name)
            field.widget.attrs = {"class": 'form-control m-b-15'}


class MemberInfoModelForm(forms.ModelForm):
    class Meta:
        model = models.member
        fields = ["name","phone","sex","birthday","time"]
        widgets = {
            'birthday':forms.DateInput(attrs={'class': 'form-control datepicker-input'}),
            'time':forms.DateInput(attrs={'class': 'form-control datepicker-input'}),
        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs = {"class": 'form-control m-b-15'}
            if name == 'birthday':
                field.widget.attrs = {'class': 'form-control m-b-15 datepicker-input',"data-date-format":"yyyy-mm-dd"}
            if name == 'time':
                field.widget.attrs = {'class': 'form-control m-b-15 datepicker-input',"data-date-format":"yyyy-mm-dd"}